﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using WinScriptEngine.Parses.Scope;

namespace WinScriptEngine.Parses.Interface
{

    [Serializable]
    public class UndefinedException : Exception
    {
        public UndefinedException() { }
        public UndefinedException(string message) : base(message) { }
        public UndefinedException(string message, Exception inner) : base(message, inner) { }
        protected UndefinedException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }
    [Serializable]
    public class RuntimeException : Exception
    {
        public RuntimeException() { }
        public RuntimeException(string message) : base(message) { }
        public RuntimeException(string message, Exception inner) : base(message, inner) { }
        protected RuntimeException(SerializationInfo info, StreamingContext context) : base(info, context) { }
    }
    interface IParse
    {
        /// <summary>
        /// 保留，将来使用
        /// </summary>
        public string VTypeName { get; }

        /// <summary>
        /// 是否可解析
        /// </summary>
        /// <param name="upper">前一个数值</param>
        /// <param name="curChar">当前的第一个字符</param>
        /// <returns></returns>
        bool TryParse(ref Metadata upper, char curChar);

        /// <summary>
        /// 解析为Value
        /// </summary>
        /// <param name="upper"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        Metadata Parse(ref Metadata upper, IEnumerator<char> position);
        /// <summary>
        /// 执行动作
        /// </summary>
        /// <param name="vCpu"></param>
        /// <returns></returns>
        bool Invoke(InvokeEnvironment vCpu);
    }
}
